<?php
//容器注册模块
$container['db'] = function ($c) {
    include_once SYSTEM_PATH . '/app/lib/BasePdo.class.php';
    $pdo = new BasePdo($c['settings']['db']);
    return $pdo;
};
$container['logger'] = function ($c) {
    $logger = new \Monolog\Logger($c['settings']['logger']['name']);
    $file_handler = new \Monolog\Handler\StreamHandler($c['settings']['logger']['path']);
    $logger->pushHandler($file_handler);
    return $logger;
};
$container['view'] = function ($c) {
    $smarty = new Smarty();
    $smarty->template_dir = $c['settings']['view']['template_dir'];
    $smarty->compile_dir = $c['settings']['view']['compile_dir'];
    $smarty->cache_dir = $c['settings']['view']['cache_dir'];
    $smarty->caching = $c['settings']['view']['caching'];
    $smarty->cache_lifetime = $c['settings']['view']['cache_lifetime'];
    $smarty->left_delimiter = $c['settings']['view']['left_delimiter'];
    $smarty->right_delimiter = $c['settings']['view']['right_delimiter'];
    return $smarty;
};
$container['guard'] = function () {
    $Guard=new \Slim\Csrf\Guard;
    $Guard->validateStorage();
    return $Guard;
};
$container['checkfrom'] = function () {
    include_once SYSTEM_PATH . '/app/lib/CheckForm.class.php';

    return new CheckForm();
};
$container['page'] = function ($c) {
    return $c['settings']['page'];
};
$container['type'] = function ($c) {
    return $c['settings']['type'];
};
$container['redis'] = function ($c) {
    $rc=$c['settings']['redis'];

    $redis=new Redis();
    $redis->connect($rc['host'],$rc['port']);
    if(!empty($rc['password'])){
        $redis->auth($rc['password']);
    }

    if($redis){
        return $redis;
    }else{
        return '连接redis失败';
    }


};
$container['weichat'] = function ($c) {
    return $c['settings']['weichat'];
};
$container['curl'] = function () {

    return new Curl\Curl();
};
$container['msg'] = function ($c) {

    return $c['settings']['msg'];
};





?>